//
//  BecomeExpertView.m
//  DJS
//
//  Created by 浪尖渝力 on 2018/2/9.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "BecomeExpertView.h"
#import "selectRegionView.h"
#import "jianJieView2ViewController.h"
@implementation BecomeExpertView

-(void)creatView{
    self.backgroundColor=_LightGrey;
    
    _scrollView=[UIScrollView new];
    [self addSubview:_scrollView];
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    _scrollView.scrollsToTop =NO;
    
    _scrollView.showsVerticalScrollIndicator = FALSE;
    _scrollView.showsHorizontalScrollIndicator = FALSE;
    _scrollView.bounces = NO;
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.viewController.automaticallyAdjustsScrollViewInsets = NO;
    }
    UIView *topView=[UIView new];
    [_scrollView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.mas_equalTo(NAV_HEIGHT+5);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(264);
    }];
    topView.layer.cornerRadius=4;
    topView.backgroundColor=[UIColor whiteColor];
    [self creatTopView:topView];
    
    
    UIView *bottomView=[UIView new];
    [_scrollView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(10);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(371);
    }];
    bottomView.layer.cornerRadius=4;
    bottomView.backgroundColor=[UIColor whiteColor];
    [self creatBottomView:bottomView];
    
    UIView *jieShaoView=[UIView new];
    [_scrollView addSubview:jieShaoView];
    [jieShaoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.mas_equalTo(bottomView.mas_bottom).mas_equalTo(10);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(101);
    }];
    jieShaoView.layer.cornerRadius=4;
    jieShaoView.backgroundColor=[UIColor whiteColor];
    [self creatJieShaoView:jieShaoView];
    
    UIButton *btn=[UIButton new];
    [_scrollView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.width.mas_equalTo(_mainW-40);
        make.top.mas_equalTo(jieShaoView.mas_bottom).mas_equalTo(50);
        make.height.mas_equalTo(50);
    }];
    btn.layer.cornerRadius=10;
    btn.backgroundColor=_backgroundColor;
    [btn setTitle:@"提交" forState:0];
    [btn setTitleColor:[UIColor whiteColor] forState:0];
    [btn addTarget:self action:@selector(tiJiao:) forControlEvents:UIControlEventTouchUpInside];
    _scrollView.contentSize = CGSizeMake(0, 930);
    
}

-(void)creatTopView:(UIView *)topView{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    
    UIView *imageView=[UIView new];
    [topView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(60);
    }];
    
    UILabel *imageLabel=[UILabel new];
    [imageView addSubview:imageLabel];
    [imageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    imageLabel.text=@"头像";
    imageLabel.font=[UIFont systemFontOfSize:17];
    imageLabel.textColor=ColorWithRGB(49, 49, 49);
    
    
    UIImageView *userImage=[UIImageView new];
    [imageView addSubview:userImage];
    [userImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(45);
    }];
    userImage.layer.masksToBounds=YES;
    userImage.layer.cornerRadius=45/2;
    NSString *wl_practice_photo=[userDic objectForKey:@"waiter_icon"];
    if ([ZQTools charIsNil:wl_practice_photo]) {
        userImage.image=[UIImage imageNamed:@"未登录头像"];
    }
    else
    {
        wl_practice_photo=[NSString stringWithFormat:@"%@%@",_addressUrl,wl_practice_photo];
        NSURL *url=[NSURL URLWithString:wl_practice_photo];
        [userImage sd_setImageWithURL:url];
    }

    
    UIView *xianView=[UIView new];
    [topView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(imageView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIView *nameView=[UIView new];
    [topView addSubview:nameView];
    [nameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView.mas_bottom);
    }];
    
    UILabel *nameLabel=[UILabel new];
    [nameView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    nameLabel.text=@"姓名";
    nameLabel.font=[UIFont systemFontOfSize:17];
    nameLabel.textColor=ColorWithRGB(49, 49, 49);
    
    UILabel *nameLabel2=[UILabel new];
    [nameView addSubview:nameLabel2];
    [nameLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(150);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(35);
        make.right.mas_equalTo(-10);
    }];
    NSString *user_nickname=[userDic objectForKey:@"waiter_name"];
    if ([ZQTools charIsNil:user_nickname]) {
        user_nickname=@"";
    }
    nameLabel2.text=user_nickname;
    nameLabel2.textColor=ColorWithRGB(49, 49, 49);
    nameLabel2.textAlignment=NSTextAlignmentRight;
    nameLabel2.font=[UIFont systemFontOfSize:17];
    
    UIView *xianView2=[UIView new];
    [topView addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(nameView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView2.backgroundColor=_LightGrey;

    UIView *ageView=[UIView new];
    [topView addSubview:ageView];
    [ageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView2.mas_bottom);
    }];
    
    UILabel *ageLabel=[UILabel new];
    [ageView addSubview:ageLabel];
    [ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    ageLabel.text=@"年龄";
    ageLabel.textColor=ColorWithRGB(29, 29, 29);
    ageLabel.font=[UIFont systemFontOfSize:17];
    
    UILabel *ageLabel2=[UILabel new];
    [ageView addSubview:ageLabel2];
    [ageLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(nameLabel2);
        make.centerY.mas_equalTo(0);
    }];
    NSNumber *waiter_age=[userDic objectForKey:@"waiter_age"];
    if ([waiter_age isKindOfClass:[NSNull class]]) {
        waiter_age=@0;
    }

    ageLabel2.text=[NSString stringWithFormat: @"%@",waiter_age];
    ageLabel2.textColor=ColorWithRGB(49, 49, 49);
    ageLabel2.textAlignment=NSTextAlignmentRight;
    ageLabel2.font=[UIFont systemFontOfSize:17];
    
    UIView *xianView4=[UIView new];
    [topView addSubview:xianView4];
    [xianView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(ageView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView4.backgroundColor=_LightGrey;
    
    
    UIView *jiguanView=[UIView new];
    [topView addSubview:jiguanView];
    [jiguanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView4.mas_bottom);
    }];
    
    UILabel *jiGuanLabel=[UILabel new];
    [jiguanView addSubview:jiGuanLabel];
    [jiGuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    jiGuanLabel.text=@"籍贯";
    jiGuanLabel.textColor=ColorWithRGB(29, 29, 29);
    jiGuanLabel.font=[UIFont systemFontOfSize:17];
    
    UILabel *jiGuanLable2=[UILabel new];
    [jiguanView addSubview:jiGuanLable2];
    [jiGuanLable2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(nameLabel2);
        make.centerY.mas_equalTo(0);
    }];
    NSString *waiter_place=[userDic objectForKey:@"waiter_place"];
    jiGuanLable2.text=waiter_place;
   
    jiGuanLable2.textColor=ColorWithRGB(49, 49, 49);
    jiGuanLable2.textAlignment=NSTextAlignmentRight;
    jiGuanLable2.font=[UIFont systemFontOfSize:17];
    
    UIView *xianView5=[UIView new];
    [topView addSubview:xianView5];
    [xianView5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(jiguanView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView5.backgroundColor=_LightGrey;
    
    
    UIView *diQuView=[UIView new];
    [topView addSubview:diQuView];
    [diQuView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView5.mas_bottom);
    }];
    
    UILabel *diquLabel=[UILabel new];
    [diQuView addSubview:diquLabel];
    [diquLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    diquLabel.text=@"身份证号";
    diquLabel.textColor=ColorWithRGB(29, 29, 29);
    diquLabel.font=[UIFont systemFontOfSize:17];
    
    
    UILabel *addLabel=[UILabel new];
    [diQuView addSubview:addLabel];
    [addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(150);
    }];
    NSString *wl_city_name=[userDic objectForKey:@"waiter_carded"];
    addLabel.text=wl_city_name;
    addLabel.textColor=ColorWithRGB(49, 49, 49);
    addLabel.font=[UIFont systemFontOfSize:17];
    addLabel.textAlignment=NSTextAlignmentRight;

}
-(void)creatBottomView:(UIView *)topView{
    UIView *LSView=[UIView new];
    [topView addSubview:LSView];
    [LSView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(0);
    }];
    
    UILabel *LSLabel=[UILabel new];
    [LSView addSubview:LSLabel];
    [LSLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    LSLabel.text=@"职业";
    LSLabel.font=[UIFont systemFontOfSize:17];
    LSLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _GSText=[UITextField new];
    [LSView addSubview:_GSText];
    [_GSText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.left.mas_equalTo(150);
        make.height.mas_equalTo(35);
        make.centerY.mas_equalTo(0);
    }];
    NSString *wl_firm=[_dic objectForKey:@"cr_careers"];
    if ([ZQTools charIsNil:wl_firm]) {
        _GSText.placeholder=@"请输入目前相关职业";
    }else{
        _GSText.text=wl_firm;
    }
    _GSText.textColor=ColorWithRGB(49, 49, 49);
    _GSText.textAlignment=NSTextAlignmentRight;
    _GSText.delegate=self;
    _GSText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView2=[UIView new];
    [topView addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(LSView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView2.backgroundColor=_LightGrey;
    
    
    UIView *ZZView=[UIView new];
    [topView addSubview:ZZView];
    [ZZView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView2.mas_bottom);
    }];
    
    UILabel *ZZLabel=[UILabel new];
    [ZZView addSubview:ZZLabel];
    [ZZLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    ZZLabel.text=@"单位";
    ZZLabel.font=[UIFont systemFontOfSize:17];
    ZZLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _ZYText=[UITextField new];
    [ZZView addSubview:_ZYText];
    [_ZYText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_GSText);
        make.centerY.mas_equalTo(0);
    }];
    NSString *wl_practice=[_dic objectForKey:@"cr_work"];
    if ([ZQTools charIsNil:wl_practice]) {
        _ZYText.placeholder=@"请输入所在单位全名";
    }else{
        _ZYText.text=wl_practice;
    }
    _ZYText.textColor=ColorWithRGB(49, 49, 49);
    _ZYText.textAlignment=NSTextAlignmentRight;
    _ZYText.delegate=self;
    _ZYText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView3=[UIView new];
    [topView addSubview:xianView3];
    [xianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(ZZView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView3.backgroundColor=_LightGrey;
    
    UIView *diQuView=[UIView new];
    [topView addSubview:diQuView];
    [diQuView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView3.mas_bottom);
    }];
    
    UILabel *diquLabel=[UILabel new];
    [diQuView addSubview:diquLabel];
    [diquLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    diquLabel.text=@"地区";
    diquLabel.textColor=ColorWithRGB(29, 29, 29);
    diquLabel.font=[UIFont systemFontOfSize:17];
    
    UIImageView *jianTou=[UIImageView new];
    [diQuView addSubview:jianTou];
    [jianTou mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(15);
    }];
    jianTou.image=[UIImage imageNamed:@"iconfont-fanhui-拷贝-3"];
    
    _addLabel=[UILabel new];
    [diQuView addSubview:_addLabel];
    [_addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(jianTou.mas_left).mas_equalTo(-5);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(150);
    }];
    
    NSString *cr_area_name=[_dic objectForKey:@"cr_area_name"];
    NSString *wl_city_name=[_dic objectForKey:@"cr_city_name"];
    NSString *cr_province_name=[_dic objectForKey:@"cr_province_name"];

    if ([ZQTools charIsNil:cr_province_name]) {
        _addLabel.text=@"请选择";
    }else{
        _addLabel.text=[NSString stringWithFormat:@"%@ %@ %@",cr_area_name,wl_city_name,cr_province_name];
    }
    _addLabel.textColor=ColorWithRGB(49, 49, 49);
    _addLabel.font=[UIFont systemFontOfSize:17];
    _addLabel.textAlignment=NSTextAlignmentRight;
    diQuView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGestur13 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectAdd:)];
    [diQuView addGestureRecognizer:tapGestur13];
    
    
    
    UIView *xianView5=[UIView new];
    [topView addSubview:xianView5];
    [xianView5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(diQuView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView5.backgroundColor=_LightGrey;
    
    
    UIView *XiangXiView=[UIView new];
    [topView addSubview:XiangXiView];
    [XiangXiView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView5.mas_bottom);
    }];
    
    
    UILabel *xiangXiLabel=[UILabel new];
    [XiangXiView addSubview:xiangXiLabel];
    [xiangXiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    xiangXiLabel.text=@"详细地址";
    xiangXiLabel.textColor=ColorWithRGB(29, 29, 29);
    xiangXiLabel.font=[UIFont systemFontOfSize:17];

    _XXText=[UITextField new];
    [XiangXiView addSubview:_XXText];
    [_XXText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_GSText);
        make.centerY.mas_equalTo(0);
    }];
    NSString *cr_address=[_dic objectForKey:@"cr_address"];
    if ([ZQTools charIsNil:cr_address]) {
        _XXText.placeholder=@"请输入详细地址";
    }else{
        _XXText.text=cr_address;
    }
    _XXText.textColor=ColorWithRGB(49, 49, 49);
    _XXText.textAlignment=NSTextAlignmentRight;
    _XXText.delegate=self;
    _XXText.returnKeyType=UIReturnKeyDone;

    
    
    
    UIView *xianView6=[UIView new];
    [topView addSubview:xianView6];
    [xianView6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(XiangXiView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView6.backgroundColor=_LightGrey;

    
    
    
    
    UIView *SCZView=[UIView new];
    [topView addSubview:SCZView];
    [SCZView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView6.mas_bottom);
    }];
    
    UILabel *SCZLabel=[UILabel new];
    [SCZView addSubview:SCZLabel];
    [SCZLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    SCZLabel.text=@"上传行业资格证书";
    SCZLabel.font=[UIFont systemFontOfSize:17];
    SCZLabel.textColor=ColorWithRGB(49, 49, 49);
    
    NSString *wl_practice_photo=[_dic objectForKey:@"cr_certificate"];
    
    _ZYImage=[UIImageView new];
    [topView addSubview:_ZYImage];
    [_ZYImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(40);
        make.height.width.mas_equalTo(100);
        make.top.mas_equalTo(SCZView.mas_bottom);
    }];
    if ([ZQTools charIsNil:wl_practice_photo]) {
        _ZYNum=1;
        _ZYImage.image=[UIImage imageNamed:@"上传"];
    }
    else
    {
        _ZYNum=2;
        wl_practice_photo=[NSString stringWithFormat:@"%@%@",_addressUrl,wl_practice_photo];
        NSURL *url=[NSURL URLWithString:wl_practice_photo];
        [_ZYImage sd_setImageWithURL:url];
    }
    _ZYImage.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userIconChange:)];
    [_ZYImage addGestureRecognizer:tapGesture];
    

}

-(void)creatJieShaoView:(UIView *)topView{
    
    UIView *LSView=[UIView new];
    [topView addSubview:LSView];
    [LSView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(0);
    }];
    
    UILabel *LSLabel=[UILabel new];
    [LSView addSubview:LSLabel];
    [LSLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    LSLabel.text=@"擅长领域";
    LSLabel.font=[UIFont systemFontOfSize:17];
    LSLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _SCText=[UITextField new];
    [LSView addSubview:_SCText];
    [_SCText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.left.mas_equalTo(150);
        make.height.mas_equalTo(35);
        make.centerY.mas_equalTo(0);
    }];
    NSString *wl_firm=[_dic objectForKey:@"cr_skilful"];
    if ([ZQTools charIsNil:wl_firm]) {
        _SCText.placeholder=@"请输入自己擅长领域";
    }else{
        _SCText.text=wl_firm;
    }
    _SCText.textColor=ColorWithRGB(49, 49, 49);
    _SCText.textAlignment=NSTextAlignmentRight;
    _SCText.delegate=self;
    _SCText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView=[UIView new];
    [topView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(_mainW-30);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIView *jianJieView=[UIView new];
    [topView addSubview:jianJieView];
    [jianJieView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
    }];
    jianJieView.layer.cornerRadius=4;
    jianJieView.backgroundColor=[UIColor whiteColor];
    jianJieView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToJianJie:)];
    [jianJieView addGestureRecognizer:tapGesture2];
    
    UILabel *imageLabel=[UILabel new];
    [jianJieView addSubview:imageLabel];
    [imageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    imageLabel.text=@"个人简介";
    imageLabel.font=[UIFont systemFontOfSize:17];
    imageLabel.textColor=ColorWithRGB(49, 49, 49);
    
    
    UIImageView *jianTou=[UIImageView new];
    [jianJieView addSubview:jianTou];
    [jianTou mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(15);
    }];
    jianTou.image=[UIImage imageNamed:@"iconfont-fanhui-拷贝-3"];
}
-(IBAction)tiJiao:(id)sender{
    
    
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"waiter_id"];
    NSString *waiter_id=[NSString stringWithFormat:@"%@",waiter_id1];
    
    NSString *cr_careers=_GSText.text;
    NSString *cr_work=_ZYText.text;
    
    NSString *cr_address=_XXText.text;

    NSDictionary *addDic1=_tableArr[0];
    NSDictionary *addDic2=_tableArr[1];
    NSDictionary *addDic3=_tableArr[2];
    
    
    
    if (_tableArr.count==0&&[ZQTools charIsNil:[_dic objectForKey:@"cr_province_name"]]) {
        [ZQTools svpInfo:@"请先选择地区"];
        return;
    }
    
    
    
    
    NSNumber *cr_area_id2=[addDic3 objectForKey:@"id"];
    NSString *cr_area_id=[NSString stringWithFormat:@"%@",cr_area_id2];
    
    
    NSNumber *cr_city_id2=[addDic2 objectForKey:@"id"];
    NSString *wl_city_id=[NSString stringWithFormat:@"%@",cr_city_id2];

    
    NSNumber *cr_province_id2=[addDic1 objectForKey:@"id"];
    NSString *cr_province_id=[NSString stringWithFormat:@"%@",cr_province_id2];
    
    
    NSString *cr_skilful=_SCText.text;
    
    if ([ZQTools charIsNil:cr_address]) {
        [ZQTools svpInfo:@"请先填写详细地址"];
        return;
    }
    NSMutableDictionary *typeDic=[NSMutableDictionary dictionaryWithCapacity:0];
    [typeDic setObject:waiter_id forKey:@"waiter_id"];
    [typeDic setObject:token forKey:@"token"];
    [typeDic setObject:@"1" forKey:@"user_role"];
    [typeDic setObject:cr_careers forKey:@"cr_careers"];
    [typeDic setObject:cr_work forKey:@"cr_work"];
    [typeDic setObject:cr_skilful forKey:@"cr_skilful"];
    
    if (_tableArr.count!=0) {
        [typeDic setObject:wl_city_id forKey:@"cr_city_id"];
        [typeDic setObject:cr_province_id forKey:@"cr_province_id"];
        [typeDic setObject:cr_area_id forKey:@"cr_area_id"];
    }
   
    
    [typeDic setObject:cr_address forKey:@"cr_address"];
    
    NSMutableArray *imageArr=[NSMutableArray arrayWithCapacity:0];
    
  
    if (_ZYNum==2) {
        UIImage *usrImge2=_ZYImage.image;
        NSDictionary *dic3=[NSDictionary dictionaryWithObjectsAndKeys:usrImge2,@"image",@"cr_certificate",@"fileName", nil];
        [imageArr addObject:dic3];
    }
 
    
    [ZQTools afnPostImageWithDict:typeDic WithAddressUrl:@"waiter/waiter/apply_expert" withImageArr:imageArr withFileName:nil fileOrImg:@"image" WithViewController:self.viewController success:^(id responseObject) {
        [ZQTools svpInfo:@"提交成功"];
        [self.viewController.navigationController popViewControllerAnimated:YES];
    }];
    
    
}

-(void)pushToJianJie:(UITapGestureRecognizer *)tap{
    jianJieView2ViewController *jianjie=[[jianJieView2ViewController alloc] init];
    jianjie.dic=self.dic;
    [ZQTools pushNextViewController:self.viewController andRootController:jianjie];
}

-(void)selectAdd:(UITapGestureRecognizer *)tap{
    NSDictionary *dic2=[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"id", nil];
    [ZQTools AFNPostDataUrl:@"api/index/area_list" Dict:dic2 andTableView:nil  andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        selectRegionView *lawView=[selectRegionView new];
        [self addSubview:lawView];
        [lawView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.mas_equalTo(0);
        }];
        lawView.tableArr=responseObject;
        lawView.index2=3;
        [lawView creatView];
        lawView.customSelectedBlock = ^(NSArray *tableArr) {
            _tableArr=tableArr;
            NSDictionary *dic=tableArr[2];
            _selectAddDic=tableArr[2];
            NSString *mergename=[dic objectForKey:@"mergename"];
            NSArray *arr=[mergename componentsSeparatedByString:@","];
            NSString *Str=@"";
            for (int i=1; i<arr.count; i++) {
                Str=[NSString stringWithFormat:@"%@ %@",Str,arr[i]];
            }
            _addLabel.text=Str;
        };
        
    } anderrorBlock:nil];
    
}

-(void) userIconChange:(UITapGestureRecognizer *)tap{
    [_XXText resignFirstResponder];
    [_GSText resignFirstResponder];
    [_SCText resignFirstResponder];
    [_ZYText resignFirstResponder];

    UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle: @"" message: @"拍照或从相册中选择" preferredStyle: UIAlertControllerStyleActionSheet];
    
    [actionSheetController addAction: [UIAlertAction actionWithTitle:@"打开相册"style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        
        [self LocalPhoto];
        
    }]];
    [actionSheetController addAction: [UIAlertAction actionWithTitle: @"拍照" style: UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
        [self locaXiangJi];
        
        
    }]];
    
    [actionSheetController addAction: [UIAlertAction actionWithTitle:@"取消"style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) {}]];
    
    [self.viewController presentViewController: actionSheetController animated:YES completion:^{}];
    
}
-(void)locaXiangJi{
    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
    
    UIImagePickerControllerQualityType qualityType = UIImagePickerControllerQualityTypeHigh;
    
    /*判断是否有相机*/
    
    if([UIImagePickerController isSourceTypeAvailable : UIImagePickerControllerSourceTypeCamera]){
        
        UIImagePickerController *picker = [[UIImagePickerController alloc]init];
        
        picker.delegate=self;
        
        /*设置拍照后的图片可被编辑*/
        
        picker.allowsEditing=YES;
        
        /*资源类型为照相机*/
        
        picker.sourceType= sourceType;
        
        /*品质为高*/
        
        picker.videoQuality= qualityType;
        
        [self.viewController presentViewController: picker animated:YES completion:^{
            
            
        }];
        
    }else{
        //        [self alertTitle:@"该设备无摄像头"];
        
    }
    
}
-(void)LocalPhoto
{
    
    UIImagePickerController *picker = [[UIImagePickerController alloc]init];
    
    /*资源类型为图片库*/
    
    picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
    
    picker.delegate=self;
    
    /*设置选择后的图片可被编辑*/
    
    picker.allowsEditing=YES;
    
    [self.viewController presentViewController:picker animated:YES completion:^{
        
        
    }];
    
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    
    [picker dismissViewControllerAnimated:YES completion:^{
        
        UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
        _ZYNum=2;
        _ZYImage.image=image;

    }];
    
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string{
    if ([[[UITextInputMode currentInputMode]primaryLanguage] isEqualToString:@"emoji"]) {
        return NO;
    }
    return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{

    [textField resignFirstResponder];
    return YES;
}
@end
